﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Jemgine.Gui
{
    public class RadialLayout
    {
        Vector2 Center;
        float CurrentAngle;
        float AngleStep;
        float Radius;

        public void BeginLayout(Vector2 Center, float Radius, int Places)
        {
            this.Center = Center;
            CurrentAngle = 0.0f;
            AngleStep = (float)(2.0f * System.Math.PI) / (float)Places;
            this.Radius = Radius;
        }

        public Rectangle PositionItem(Vector2 Dimensions)
        {
            Vector2 Vec = new Vector2(0, Radius);
            var M = Matrix.CreateRotationZ(CurrentAngle);
            CurrentAngle += AngleStep;
            Vec = Vector2.Transform(Vec, M);
            Vec = Center + Vec;
            return new Rectangle(Vec.X - Dimensions.X / 2, Vec.Y - Dimensions.Y / 2, Dimensions.X, Dimensions.Y);
        }
    }
}
